package com.java110.mall.cart.bmo.housekeepingResourceFee.impl;


import com.java110.mall.cart.bmo.housekeepingResourceFee.IGetHousekeepingResourceFeeBMO;
import com.java110.intf.cart.IHousekeepingResourceFeeInnerServiceSMO;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import com.java110.dto.housekeeping.HousekeepingResourceFeeDto;


import java.util.ArrayList;
import java.util.List;

@Service("getHousekeepingResourceFeeBMOImpl")
public class GetHousekeepingResourceFeeBMOImpl implements IGetHousekeepingResourceFeeBMO {

    @Autowired
    private IHousekeepingResourceFeeInnerServiceSMO housekeepingResourceFeeInnerServiceSMOImpl;

    /**
     *
     *
     * @param  housekeepingResourceFeeDto
     * @return 订单服务能够接受的报文
     */
    public ResponseEntity<String> get(HousekeepingResourceFeeDto housekeepingResourceFeeDto) {


        int count = housekeepingResourceFeeInnerServiceSMOImpl.queryHousekeepingResourceFeesCount(housekeepingResourceFeeDto);

        List<HousekeepingResourceFeeDto> housekeepingResourceFeeDtos = null;
        if (count > 0) {
            housekeepingResourceFeeDtos = housekeepingResourceFeeInnerServiceSMOImpl.queryHousekeepingResourceFees(housekeepingResourceFeeDto);
        } else {
            housekeepingResourceFeeDtos = new ArrayList<>();
        }

        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) housekeepingResourceFeeDto.getRow()), count, housekeepingResourceFeeDtos);

        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);

        return responseEntity;
    }

}
